package 多线程初阶.线程的创建方式;

import static java.lang.Thread.sleep;

//通过实现Runnable接口
class run implements  Runnable{
    public void run() {
        while (true){
            System.out.println("thread is run");
            try {
                sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

public class Demo2 {
    public static void main(String[] args) throws InterruptedException {
        Runnable runnable = new run();
        Thread thread = new Thread(runnable);
        thread.start();
        while (true) {
            System.out.println("main is run");
            sleep(1000);
        }
    }
}
